package com.linyaonan.leetcode.easy._1103;

/**
 * @author: Lin
 * @date: 2020/1/12
 */
public class DistributeCandies {
    public int[] distributeCandies(int candies, int num_people) {
        int[] result = new int[num_people];
        int index = 0;
        while (candies > 0) {
            result[index % num_people] += Math.min(index + 1, candies);
            index++;
            candies -= index;
        }
        return result;
    }
}
